define(function (require) {
    function a() {
        i("#rate-range").slider({
            range: !0, min: 4, max: 18, values: [4, 18], slide: function (a, b) {
                var c = b.values[0], d = b.values[1], e = "";
                if (c == d) {
                    var f = i(this).slider("option", "min"), g = i(this).slider("option", "max");
                    e = c == d && d == f ? "小于" + c + "%" : c == d && d == g ? "大于" + d + "%" : d + "%"
                } else e = c + "% - " + d + "%";
                i("#rate-val").html(e)
            }
        }), i("#rate-val").html(i("#rate-range").slider("values", 0) + "% - " + i("#rate-range").slider("values", 1) + "%"), i("#month-range").slider({
            range: !0,
            min: 0,
            max: 18,
            values: [0, 18],
            slide: function (a, b) {
                var c = b.values[0], d = b.values[1], e = "";
                if (c == d) {
                    var f = i(this).slider("option", "min"), g = i(this).slider("option", "max");
                    e = c == d && d == f ? "小于" + c + "个月" : c == d && d == g ? "大于" + d + "个月" : d + "个月"
                } else e = c + " - " + d + "个月";
                i("#month-val").html(e)
            }
        }), i("#month-val").html(i("#month-range").slider("values", 0) + " - " + i("#month-range").slider("values", 1) + "个月");
        var a = ["等额本息", "利随本清", "每月付息", "每季付息"];
        i("#paytype-range").slider({
            min: 0, max: 3, value: 1, slide: function (b, c) {
                var d = c.value;
                i("#paytype-val").html(a[d])
            }
        }), i("#paytype-val").html(a[i("#paytype-range").slider("value")]), i(".switch").click(function () {
            var a = i(this);
            a.hasClass("off") ? (a.removeClass("off"), a.next().show(), a.parent().next().show(), a.next().next().hide()) : (a.addClass("off"), a.next().hide(), a.parent().next().hide(), a.next().next().show())
        }), i(".list-title .switch").unbind().click(function () {
            var a = i(this);
            a.hasClass("off") ? (a.removeClass("off"), i("#new-filter").show()) : (a.addClass("off"), i("#new-filter").hide()), g()
        }), i("#safe-range .glyphicon").mouseover(function () {
            var a = i(this).index("#safe-range .glyphicon") + 1, b = "glyphicon-star", c = "glyphicon-star-empty";
            i("#safe-range .glyphicon").removeClass(b).addClass(c), i("#safe-range .glyphicon:lt(" + a + ")").removeClass(c).addClass(b), i("#safe-val").html(a + "星级")
        }), i(".search_btn").click(function () {
            var a = ["1002", "1003", "1004", "1018"], b = i("#rate-val:visible").length ? i("#rate-range").slider("values", 0) : "", d = i("#rate-val:visible").length ? i("#rate-range").slider("values", 1) : "", e = i("#month-val:visible").length ? i("#month-range").slider("values", 0) : "", f = i("#month-val:visible").length ? i("#month-range").slider("values", 1) : "", g = i("#safe-val:visible").length ? parseInt(i("#safe-val").text()) : "", h = i("#paytype-val:visible").length ? a[i("#paytype-range").slider("value")] : "";
            b = "10" == b && "10" == d ? "0" : b, g = g ? 7 - g : "";
            var j = {
                pageIndex: 0,
                pageSize: m,
                minApr: b,
                maxApr: d,
                minMonth: e,
                maxMonth: f,
                gradeId: g,
                repaymentType: h
            };
            i("#loan-list").html(""), i("#more-item").show(), c(null, j)
        }), i("#search-box a").click(function () {
            i(this).addClass("btn-warning").siblings("a").removeClass("btn-warning"), "0" == i(this).attr("data") ? (i(this).parent().find("input").attr("min", i(this).attr("min")), i(this).parent().find("input").attr("max", i(this).attr("max"))) : i(this).parent().find("input").attr("data", i(this).attr("data"));
            var a = i("#apr").attr("min"), b = i("#apr").attr("max"), d = i("#month").attr("min"), e = i("#month").attr("max"), f = i("#gradeId").attr("data"), g = i("#repaymentType").attr("data"), h = {
                pageIndex: 0,
                pageSize: "6",
                minApr: a,
                maxApr: b,
                minMonth: d,
                maxMonth: e,
                gradeId: f,
                repaymentType: g
            };
            i("#loan-list").html(""), c(null, h)
        }), i("#more-item").click(function () {
            if ("disabled" != i(this).attr("disabled")) {
                l++;
                var a = i.extend(o, {pageIndex: l});
                c(null, a)
            }
        })
    }

    function b() {
        var a = ["1002", "1003", "1004", "1018"], b = i("#rate-val:visible").length ? i("#rate-range").slider("values", 0) : "", c = i("#rate-val:visible").length ? i("#rate-range").slider("values", 1) : "", d = i("#month-val:visible").length ? i("#month-range").slider("values", 0) : "", e = i("#month-val:visible").length ? i("#month-range").slider("values", 1) : "", f = i("#safe-val:visible").length ? parseInt(i("#safe-val").text()) : "", g = i("#paytype-val:visible").length ? a[i("#paytype-range").slider("value")] : "";
        b = "10" == b && "10" == c ? "0" : b, f = f ? 7 - f : "";
        var h = {minApr: b, maxApr: c, minMonth: d, maxMonth: e, gradeId: f, repaymentType: g};
        return h
    }

    function c(a, d) {
        a = a ? a : 0;
        var e = d ? d : {pageIndex: a, pageSize: m};
        if (!i("#filter-switch").hasClass("off")) {
            var f = b();
            e = i.extend(e, f)
        }
        o = e, q.option("version", "22"), p = !1, q.get("getLoanList.do", e, function (b) {
            p = !0, i.mobileCheck() ? (i("#more-item").show(), r.showLoanList(b, "1", "loan-list", 1)) : (r.showLoanList(b, "1", "loan-list"), i.initPage2(c, e.pageSize, a, b.result.dataTotal, i("#show-more")))
        }), q.option("version", "")
    }

    function d() {
        var a = window.location.href;
        s = a.match(/persistent/) ? "4" : a.match(/draft/) ? "5" : a.match(/resale/) ? "6" : a.match(/consume/) ? "9" : "1"
    }

    function e() {
        var a = new j;
        a.option("version", "24");
        var b = {
            1: "/loan/index.html",
            4: "/loan/persistent.html",
            5: "/loan/draft.html",
            6: "/loan/resale.html",
            7: "/loan/fund.html",
            9: "/loan/consume.html",
            12: "/loan/cast.html"
        };
        a.option("loading", !0);
        var d = "getTabList.do";
        a.get(d, {}, function (d) {
            if (a.check(d)) {
                var e = d.result.data, g = [];
                i.each(e, function (a, c) {
                    "1" == c.visible_web && b[c.value] && (s == c.value ? (g.push('<li class="active" tar="' + c.value + '"><a href="#">' + c.tab_name + "</a></li>"), n = c.totalNumber) : g.push('<li tar="' + c.value + '"><a href="' + b[c.value] + '">' + c.tab_name + "</a></li>"))
                }), i(".list-title ul").html(g.join("")), f(), c()
            }
        })
    }

    function f() {
        return i.mobileCheck() ? void require(["../lib/slide.js"], function () {
            var a = document.getElementById("list-title-box");
            i.slideMove(a, !0)
        }) : !1
    }

    function g() {
        var a = i("#footer_wrapper");
        a.hasClass("fixed-bottom") && !a.attr("isFixed") && a.attr("isFixed", 1);
        var b = i(window).height(), c = a.attr("isFixed") ? i("body").height() - 106 : i("body").height();
        b > c + 106 ? a.addClass("fixed-bottom") : a.removeClass("fixed-bottom")
    }

    function h() {
        d(), e(), a()
    }

    var i = require("jquery"), j = require("api"), k = require("loan"), l = (require("jquery_ui"), require("jquery_ui_touch"), 0), m = 9, n = 0, o = null;
    m = i.mobileCheck() ? 12 : 9;
    var p, q = new j, r = new k, s = "";
    h()
});